package com.asm.code;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.miqt.pluginlib.annotation.HookInfo;
import com.miqt.pluginlib.annotation.HookMethod;
import com.miqt.pluginlib.annotation.IgnoreMethodHook;

import java.io.FileOutputStream;
import java.io.IOException;


public class MainActivity extends Activity {

    static FileOutputStream fileOutputStream;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(v -> Toast.makeText(MainActivity.this, "onClick", Toast.LENGTH_SHORT).show());

        try {
            fileOutputStream = new FileOutputStream(getCacheDir()+"/test.txt");
            fileOutputStream.write(1);
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void ccc(View view){
        view.setOnClickListener(v -> {
            "aba".toString().getBytes();
        });
    }
    private  static void aaa(View view){
        view.setOnClickListener(v -> {
            "aa".toString().getBytes();
        });
    }
    private void bbb(View view){
        view.setOnClickListener(v -> {
            "aa".toString().getBytes();
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
       runOnUiThread(() -> {
           Toast.makeText(this, "xxx", Toast.LENGTH_SHORT).show();
       });
    }

    @Override
    protected void onPause() {
        super.onPause();
        new Thread(){
            @HookInfo
            @Override
            public void run() {
                super.run();
            }
        }.start();
    }

    @Override
    protected void onStart() {
        Log.d("protectedonStart", "1onCreate: "+getCacheDir().toString());
        super.onStart();
        Log.d("protectedonStart", "2onCreate: xxx1");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @HookInfo
    @Override
    protected void onStop() {
        super.onStop();
    }

    @HookMethod
    public void testHookMethod() {
        System.out.println("testHookMethod");
    }

    @IgnoreMethodHook
    public void testIgHookMethod() {
        System.out.println("testIgHookMethod");
    }
}
